package com.glsc.ngateway.common.base.repo.mysql.opmanage.report.fileupload;

import com.glsc.ngateway.common.base.domain.mysql.opmanage.report.fileupload.ImportTemplateRulesDefine;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * @author: qiyr
 * @date: 2022/8/10 10:15
 * @description: 导入文件模板格式校验规则定义
 */
@Repository
public interface ImportTemplateRulesDefineRepo extends JpaRepository<ImportTemplateRulesDefine, BigInteger>, JpaSpecificationExecutor<ImportTemplateRulesDefine> {

    @Query(value = "select * from t_import_templaterules_define where import_config_id = :configId", nativeQuery = true)
    List<ImportTemplateRulesDefine> list(@Param("configId") BigInteger configId);

    @Query(value = "select * from t_import_templaterules_define where import_config_id = :configId and sheet_name = :sheetName", nativeQuery = true)
    List<ImportTemplateRulesDefine> list(@Param("configId") BigInteger configId, @Param("sheetName") String sheetName);

    @Query(value = "select * from t_import_templaterules_define where import_config_id = :configId and sheet_index = :sheetIndex", nativeQuery = true)
    List<ImportTemplateRulesDefine> list(@Param("configId") BigInteger configId, @Param("sheetIndex") Integer sheetIndex);
}
